package graphics;

import java.awt.Graphics;
import java.util.StringTokenizer;


public class Rettangolo implements Forma{

	private int x,y,w,h;
	
	public void draw(Graphics graphics) {
		graphics.drawRect(x, y, w, h);
	}
	
	public void readFromString(String s) {
		
		StringTokenizer tok=new StringTokenizer(s," :");
		tok.nextToken();//Rettangolo
		tok.nextToken();//stringa x
		x=new Integer(tok.nextToken());
		tok.nextToken();//stringa y
		y=new Integer(tok.nextToken());
		tok.nextToken();//stringa w
		w=new Integer(tok.nextToken());
		tok.nextToken();//stringa h
		h=new Integer(tok.nextToken());
	}
	
	public String writeAsString() {
		return "Rettangolo x:"+x+" y:"+y+" w:"+w+" h:"+h;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getW() {
		return w;
	}

	public void setW(int w) {
		this.w = w;
	}

	public int getH() {
		return h;
	}

	public void setH(int h) {
		this.h = h;
	}
	

	
}
